<template>
    <a-modal
            :title="tableTitle"
            :visible="visible"
            width="1200px"
            @ok="handleOk"
            :confirmLoading="confirmLoading"
            @cancel="handleCancel"
            :maskClosable="false"
    >
        <a-form-model ref="form" :model="form">

            <a-descriptions bordered :column="2">
                <a-descriptions-item label="统一社会信用代码" :span="2">
                    <a-form-model-item>
                        {{form.creditCode}}
                    </a-form-model-item>
                </a-descriptions-item>
                <a-descriptions-item label="选择数据年份" :span="2">
                    <a-form-model-item
                            prop="year"
                            :rules="{
                                required: true,
                                message: '选择数据年份',
                                trigger: 'change',
                            }">
                        <xlDate
                                @change="yearChange"
                                data-type="year"
                                :placeholder="'选择数据年份'"
                                v-model="form.year">
                        </xlDate>
                    </a-form-model-item>
                </a-descriptions-item>
                <a-descriptions-item label="企业名称">
                    <a-form-model-item>
                        <a-input
                                :placeholder="'请输入企业名称'"
                                v-model="form.comName">
                        </a-input>
                    </a-form-model-item>
                </a-descriptions-item>
                <a-descriptions-item label="选择入驻时间">
                    <a-form-model-item>
                        <xlDate
                                :placeholder="'选择入驻时间'"
                                v-model="form.joinDate">
                        </xlDate>
                    </a-form-model-item>
                </a-descriptions-item>
                <a-descriptions-item label="是否空挂">
                    <a-form-model-item>
                        <a-radio-group v-model="form.isEmptyHanging">
                            <a-radio :value="true">
                                是
                            </a-radio>
                            <a-radio :value="false">
                                否
                            </a-radio>
                        </a-radio-group>
                    </a-form-model-item>
                </a-descriptions-item>
                <a-descriptions-item label="是否毕业">
                    <a-form-model-item>
                        <a-radio-group v-model="form.isGraduationFlag" @change="()=>{form.graduationDate = ''}">
                            <a-radio :value="true">
                                是
                            </a-radio>
                            <a-radio :value="false">
                                否
                            </a-radio>
                        </a-radio-group>
                    </a-form-model-item>
                </a-descriptions-item>
                <a-descriptions-item label="选择毕业时间">
                    <a-form-model-item>
                        <xlDate
                                :disabled="!form.isGraduationFlag"
                                :placeholder="'选择毕业时间'"
                                v-model="form.graduationDate">
                        </xlDate>
                    </a-form-model-item>
                </a-descriptions-item>
                <a-descriptions-item label="是否迁出">
                    <a-form-model-item>
                        <a-radio-group v-model="form.isLeaveFlag"  @change="()=>{form.leaveDate = ''}">
                            <a-radio :value="true">
                                是
                            </a-radio>
                            <a-radio :value="false">
                                否
                            </a-radio>
                        </a-radio-group>
                    </a-form-model-item>
                </a-descriptions-item>
                <a-descriptions-item label="迁出时间">
                    <a-form-model-item>
                        <xlDate
                                :disabled="!form.isLeaveFlag"
                                :placeholder="'选择迁出时间'"
                                v-model="form.leaveDate"
                        >
                        </xlDate>
                    </a-form-model-item>
                </a-descriptions-item>
                <a-descriptions-item label="行业领域">
                    <a-input
                            :placeholder="'请输入行业领域'"
                            v-model="form.industryDomain">
                    </a-input>
                </a-descriptions-item>
                <a-descriptions-item label="租用场地面积">
                    <a-form-model-item>
                        <a-input-number
                                :min="0"
                                :placeholder="'请输入租用场地面积'"
                                v-model="form.rentArea">
                        </a-input-number>
                    </a-form-model-item>
                </a-descriptions-item>
                <a-descriptions-item label="员工人数">
                    <a-form-model-item>
                        <a-input-number
                                :min="0"
                                :placeholder="'请输入员工人数'"
                                v-model="form.employeeNum">
                        </a-input-number>
                    </a-form-model-item>
                </a-descriptions-item>
                <a-descriptions-item label="负责人">
                    <a-form-model-item>
                        <a-input
                                :placeholder="'负责人'"
                                v-model="form.contactName">
                        </a-input>
                    </a-form-model-item>
                </a-descriptions-item>
                <a-descriptions-item label="负责人电话">
                    <a-form-model-item>
                        <a-input
                                :placeholder="'请输入负责人电话'"
                                v-model="form.contactPhone">
                        </a-input>
                    </a-form-model-item>
                </a-descriptions-item>
                <a-descriptions-item label="获投融资额(万元)">
                    <a-form-model-item>
                        <a-input-number
                                :min="0"
                                :placeholder="'请输入获投融资额'"
                                v-model="form.investAmt">
                        </a-input-number>
                    </a-form-model-item>
                </a-descriptions-item>
                <a-descriptions-item label="销售收入(万元)">
                    <a-form-model-item>
                        <a-input-number
                                :min="0"
                                :placeholder="'请输入销售收入'"
                                v-model="form.incomeAmt">
                        </a-input-number>
                    </a-form-model-item>
                </a-descriptions-item>
                <a-descriptions-item label="纳税额(万元)">
                    <a-form-model-item>
                        <a-input-number
                                :min="0"
                                :placeholder="'请输入纳税额'"
                                v-model="form.taxAmt">
                        </a-input-number>
                    </a-form-model-item>
                </a-descriptions-item>
                <a-descriptions-item label="获市级以上项目资金(万元)">
                    <a-form-model-item>
                        <a-input-number
                                :min="0"
                                :placeholder="'请输入获市级以上项目资金'"
                                v-model="form.projectAwardAmt">
                        </a-input-number>
                    </a-form-model-item>
                </a-descriptions-item>
                <a-descriptions-item label="被孵化资金投资">
                    <a-form-model-item>
                        <a-input-number
                                :min="0"
                                :placeholder="'请输入被孵化资金投资'"
                                v-model="form.incubatedFundAmt">
                        </a-input-number>
                    </a-form-model-item>
                </a-descriptions-item>
                <a-descriptions-item label="是否团队转入" v-if="form.carrierType == 2">
                    <a-form-model-item>
                        <a-radio-group v-model="form.isTeamFlag">
                            <a-radio :value="true">
                                是
                            </a-radio>
                            <a-radio :value="false">
                                否
                            </a-radio>
                        </a-radio-group>
                    </a-form-model-item>
                </a-descriptions-item>
                <a-descriptions-item label="自主知识产权申报量">
                    <a-form-model-item>
                        <a-input-number
                                :min="0"
                                :placeholder="'请输入自主知识产权申报量'"
                                v-model="form.iprGrantNum">
                        </a-input-number>
                    </a-form-model-item>
                </a-descriptions-item>
                <a-descriptions-item label="自主知识产权授权量">
                    <a-form-model-item>
                        <a-input-number
                                :min="0"
                                :placeholder="'请输入自主知识产权授权量'"
                                v-model="form.iprOwnedNum">
                        </a-input-number>
                    </a-form-model-item>
                </a-descriptions-item>
                <a-descriptions-item label="上传营业执照" :span="2">
                    <a-form-model-item>
                        <xluploadFile
                                v-model="form.licensePath"
                        ></xluploadFile>
                    </a-form-model-item>
                </a-descriptions-item>
                <a-descriptions-item label="上传合同" :span="2">
                    <a-form-model-item>
                        <xluploadFile
                                v-model="form.contractPath"
                        ></xluploadFile>
                    </a-form-model-item>
                </a-descriptions-item>
                <a-descriptions-item label="上传知识产权证明文件" :span="2">
                    <a-form-model-item>
                        <xluploadFile
                                v-model="form.iprPath"
                                :title-visible="true"
                                title="根据填报的知识产权数量合并上传相关证明材料"
                        ></xluploadFile>
                    </a-form-model-item>
                </a-descriptions-item>
                <a-descriptions-item label="上传市级以上项目证明文件" :span="2">
                    <a-form-model-item>
                        <xluploadFile
                                v-model="form.projectAwardPath"
                                :title-visible="true"
                                title="根据填报的市级以上项目合并上传相关证明材料"
                        ></xluploadFile>
                    </a-form-model-item>
                </a-descriptions-item>
                <a-descriptions-item label="是否科技型中小企业">
                    <a-form-model-item>
                        <a-radio-group v-model="form.scienceTechFlag">
                            <a-radio :value="true">
                                是
                            </a-radio>
                            <a-radio :value="false">
                                否
                            </a-radio>
                        </a-radio-group>
                    </a-form-model-item>
                </a-descriptions-item>
                <a-descriptions-item label="科小证明文件(可选)">
                    <a-form-model-item>
                        <xluploadFile
                                 :disabled="!form.scienceTechFlag"
                                v-model="form.scienceTechPath"
                        ></xluploadFile>
                    </a-form-model-item>
                </a-descriptions-item>
                <a-descriptions-item label="是否民营科技企业">
                    <a-form-model-item>
                        <a-radio-group v-model="form.privatelyFlag">
                            <a-radio :value="true">
                                是
                            </a-radio>
                            <a-radio :value="false">
                                否
                            </a-radio>
                        </a-radio-group>
                    </a-form-model-item>
                </a-descriptions-item>
                <a-descriptions-item label="民营证明文件(可选)">
                    <a-form-model-item>
                        <xluploadFile
                                :disabled="!form.privatelyFlag"
                                v-model="form.privatelyPath"
                        ></xluploadFile>
                    </a-form-model-item>
                </a-descriptions-item>
                <a-descriptions-item label="是否软件企业">
                    <a-form-model-item>
                        <a-radio-group v-model="form.softwareFlag">
                            <a-radio :value="true">
                                是
                            </a-radio>
                            <a-radio :value="false">
                                否
                            </a-radio>
                        </a-radio-group>
                    </a-form-model-item>
                </a-descriptions-item>
                <a-descriptions-item label="软件企业证明文件(可选)">
                    <a-form-model-item>
                        <xluploadFile
                                :disabled="!form.softwareFlag"
                                v-model="form.softwarePath"
                        ></xluploadFile>
                    </a-form-model-item>
                </a-descriptions-item>
                <a-descriptions-item label="是否高新技术企业">
                    <a-form-model-item>
                        <a-radio-group v-model="form.highTechFlag">
                            <a-radio :value="true">
                                是
                            </a-radio>
                            <a-radio :value="false">
                                否
                            </a-radio>
                        </a-radio-group>
                    </a-form-model-item>
                </a-descriptions-item>
                <a-descriptions-item label="高企证明文件(可选)">
                    <a-form-model-item>
                        <xluploadFile
                                :disabled="!form.highTechFlag"
                                v-model="form.highTechPath"
                        ></xluploadFile>
                    </a-form-model-item>
                </a-descriptions-item>
                <a-descriptions-item label="是否上市企业">
                    <a-form-model-item>
                        <a-radio-group v-model="form.listedFlag">
                            <a-radio :value="true">
                                是
                            </a-radio>
                            <a-radio :value="false">
                                否
                            </a-radio>
                        </a-radio-group>
                    </a-form-model-item>
                </a-descriptions-item>
                <a-descriptions-item label="上市证明文件(可选)">
                    <a-form-model-item>
                        <xluploadFile
                                :disabled="!form.listedFlag"
                                v-model="form.listedPath"
                        ></xluploadFile>
                    </a-form-model-item>
                </a-descriptions-item>
            </a-descriptions>
        </a-form-model>
    </a-modal>
</template>

<script>
    import xlDate from '@/components/formUntil/xlDate'
    import xlImage from '@/components/formUntil/xlImage'
    import xluploadFile from '@/components/formUntil/xluploadFile'
    import {carrierComMoreGetByParam, carrierEmployeePageList} from "@/assets/api";

    export default {
        name: "xlForm",
        data() {
            return {
                tableTitle: '编辑',
                visible: false,
                confirmLoading: false,
                form: {
                    ckechbox: []
                },
                rules: {},
                mainId: null
            }
        },
        components: {
            xlDate,
            xlImage,
            xluploadFile
        },
        methods: {
            handleOk() {
                this.$refs.form.validate(valid => {
                    console.log(valid)
                    if (valid) {
                        this.confirmLoading = true
                        this.$emit('handleOk', this.form)
                    } else {
                        console.log('error submit!!');
                        return false;
                    }
                });
            },
            handleCancel() {
                this.visible = false
            },
            formatData() {

            },
            yearChange() {
                carrierComMoreGetByParam({
                    param: {
                        carrierComId: this.mainId,
                        year: this.form.year
                    }
                })
                    .then(result => {
                        this.form = {
                            ...this.form,
                            ...result.result
                        }
                        this.visible = true
                    })
            },
            formatForm(form) {
                delete form.createDateTime
                delete form.modifyDateTime
                delete form.modifyBy
                delete form.createBy
                //整理字段数据 ／ 赋值 清空等
                this.mainId = form.id
                this.form = {}
                carrierComMoreGetByParam({
                    param: {
                        carrierComId: this.mainId,
                        year: form.year
                    }
                })
                    .then(result => {
                        this.form = {
                            ...this.form,
                            ...result.result
                        }
                        this.visible = true
                    })

            }
        }
    }
</script>

<style scoped lang="less">
    /deep/ .ant-form-item {
        margin: 0;
    }

    /deep/ .ant-input-number {
        width: 100%;
    }

    .xl-dateRange {
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    .ant-checkbox-group {
        display: flex;
        flex-wrap: wrap;

        .xl-checkbox {
            display: flex;
            align-items: center;

            /deep/ span:nth-child(2):not(.ant-checkbox-inner) {
                display: flex;
                justify-content: space-between;
                white-space: pre;
            }
        }
    }
</style>
